package com.hjxy.service.impl;

import com.hjxy.dao.TeacherDao;
import com.hjxy.pojo.Teacher;
import com.hjxy.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: zhangjie
 * @createDate: 2020/10/3
 * @version: 1.0
 */
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired //自动装备
    private TeacherDao teacherDao;

    @Override
    public List<Teacher> queryTeacher() {
        List<Teacher> teachers = teacherDao.queryTeacher();
//        System.out.println("teache11111r==>"+teachers);
        return teachers;
    }

    @Override
    public int addTeacher(Teacher teacher) {
        int i = teacherDao.insertByTeacher(teacher);
        return i;
    }

    @Override
    public boolean modifyOne(Teacher teacher) {
        int result = teacherDao.updateTeacher(teacher);
        return result > 0;
    }

    @Override
    public boolean addOneTeacher(Teacher teacher) {
        int result = teacherDao.addOneTeacher(teacher);
        return result > 0;
    }

    @Override
    public Teacher queryOneTeacherById(Integer teacherId) {
        Teacher teacher = teacherDao.queryOneTeacherById(teacherId);
        System.out.println(teacher+"==========");
        return teacher;
    }

    @Override
    public int deleteOneTeacher(int teacherId) {
        return teacherDao.deleteOneTeacher(teacherId);
    }
}
